


layui.define(['layer'], function (exports) {

    var format = {version: '3.1.8', layerData: {}};


    format.toPercent = function checkNum(num){

        var regPos = /^\d+(\.\d+)?$/; //非负浮点数
        var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
        if(regPos.test(num) && regNeg.test(num)){
            console.info("格式化数值到百分数失败！数值：" + num );
            return num;
        }else {
            return Math.floor(num * 100) + '%';
        }
    };

    exports('format', format);
});
